<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <body>
        <button onclick="openWindow()">查看浏览器信息</button>
    </body>
    <script>
        var body = document.getElementsByTagName("body")[0]
        var col = null;//定时器的id值
        function openWindow() {
            clearTimeout(col);
            col = setTimeout(
                function () {
                    win = open('', 'navigator', 'width=450,height=450,top=150,left=150', "false")
                    win.document.write("<button onclick=alert(" + 123 + ")>查看浏览器信息</button>");
                    win.document.write("<hr>" + "新窗口的名字：" + win.name)
                    win.document.write("<hr>" + "navigator-appCodeName:" + win.navigator.appCodeName)
                    win.document.write("<hr>" + "navigator-appName:" + win.navigator.appName)
                    win.document.write("<hr>" + "navigator-appVersion:" + win.navigator.appVersion)
                    win.document.write("<hr>" + "location-protocol:" + win.location.protocol)
                    win.document.write("<hr>" + "location-pathname:" + win.location.pathname)
                }, 2000
            )
            setTimeout(function () {
                console.log(col)
                clearTimeout(col);
                win.close()
                win2 = open('', '_self', 'width=450,height=450,top=150,left=150', "false")
                win2.document.write("<h1>延迟5秒返回主页面</h1>");
                setTimeout(function () {
                    location.replace("./董天启jsDom.html")
                }, 4000)
            }, 6000)
        }
    
    </script>
    
</html>